import React from 'react'
import {Switch,Route,Redirect} from "react-router-dom"
import "./App.less"
import PrivateRoute from './utils/PrivateRoute'
// 懒加载 组件通过 ReACT.laxy(引入)
let Register =React.lazy(()=>import("./pages/Register/Register"))
let Login =React.lazy(()=>import("./pages/login/login"))
let List =React.lazy(()=>import('./pages/List/List'))
let Index =React.lazy(()=>import('./pages/Index/Index'))
let Detail =React.lazy(()=>import('./pages/Detail/Detail'))
let Search =React.lazy(()=>import('./pages/Search/Search'))
export default function App() {
  return (
   
    <div className="con">
      {/* 路由出口 */}
        <React.Suspense fallback ={<div>正在加载中</div>}>
      <Switch >
        {/* 路由规则 */}
        <Route path="/login"  component={Login}></Route>
        <Route path="/register"  component={Register}></Route>
        <PrivateRoute path="/index"  component={Index}></PrivateRoute>
        <PrivateRoute path="/List" component={List}></PrivateRoute>
        <PrivateRoute path="/Detail/:id/:catename"  component={Detail}></PrivateRoute> 
        <PrivateRoute path="/search" component={Search}></PrivateRoute>
        {/* 重定向 */}
        
        <Redirect to="/login"></Redirect>
      </Switch>
      </React.Suspense>
    </div>
  
  )
}
